// miniprogram/pages/my/links/links.js
const app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        showComment: true,
        commentSensitiveWords: [],

        isDark: false,
        links: [
            {
                "id": 0,
                "icon": "https://gitee.com/yicm/Images/raw/master/xiaobaiai/yiming5.png",
                "nickname": "小白AI.易名",
                "description": "欢迎访问xiaobaiai.ent",
                "website": "https://xiaobaiai.net",
                "background": { "start": "#22c1c3", "end": "#fdbb2d"}
            }
        ]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        let that = this;
        if (app.globalData.config) {
            that.data.links = app.globalData.config.friend_links;

            if (app.globalData.config.global.comment) {
                that.data.showComment = true;
            } 

            that.setData({
                links: that.data.links
            })
            
            if (app.globalData.config.global.comment_filter) {
                that.setData({
                    commentSensitiveWords: app.globalData.config.global.comment_filter
                })
            }

        }

        that.setData({                    
            showComment: that.data.showComment
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
        console.log('onReachBottom');
        if (this.data.showComment) {
            let newWxComment = this.selectComponent('#NewWxComment');
            newWxComment.onReachBottom();
        }
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    linkBlockTap: function (e) {       
        wx.setClipboardData({
            data: e.currentTarget.dataset.website,
            success(res) {

            }
        })
    }
})